package com.ruoyi.indexAdvertising.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.indexAdvertising.domain.IndexAdvertising;
import com.ruoyi.indexAdvertising.mapper.IndexAdvertisingMapper;
import com.ruoyi.indexAdvertising.service.IIndexAdvertisingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 启动页广告Service业务层处理
 *
 * @author jiuyou
 * @date 2021-10-18
 */
@Service
public class IndexAdvertisingServiceImpl implements IIndexAdvertisingService
{
    @Autowired
    private IndexAdvertisingMapper indexAdvertisingMapper;

    /**
     * 查询启动页广告
     *
     * @param id 启动页广告ID
     * @return 启动页广告
     */
    @Override
    public IndexAdvertising selectIndexAdvertisingById(Long id)
    {
        return indexAdvertisingMapper.selectIndexAdvertisingById(id);
    }

    /**
     * 查询启动页广告列表
     *
     * @param indexAdvertising 启动页广告
     * @return 启动页广告
     */
    @Override
    public List<IndexAdvertising> selectIndexAdvertisingList(IndexAdvertising indexAdvertising)
    {
        return indexAdvertisingMapper.selectIndexAdvertisingList(indexAdvertising);
    }

    /**
     * 新增启动页广告
     *
     * @param indexAdvertising 启动页广告
     * @return 结果
     */
    @Override
    public int insertIndexAdvertising(IndexAdvertising indexAdvertising)
    {
        indexAdvertising.setCreateTime(DateUtils.getNowDate());
        return indexAdvertisingMapper.insertIndexAdvertising(indexAdvertising);
    }

    /**
     * 修改启动页广告
     *
     * @param indexAdvertising 启动页广告
     * @return 结果
     */
    @Override
    public int updateIndexAdvertising(IndexAdvertising indexAdvertising)
    {
        indexAdvertising.setUpdateTime(DateUtils.getNowDate());
        return indexAdvertisingMapper.updateIndexAdvertising(indexAdvertising);
    }

    /**
     * 批量删除启动页广告
     *
     * @param ids 需要删除的启动页广告ID
     * @return 结果
     */
    @Override
    public int deleteIndexAdvertisingByIds(Long[] ids)
    {
        return indexAdvertisingMapper.deleteIndexAdvertisingByIds(ids);
    }

    /**
     * 删除启动页广告信息
     *
     * @param id 启动页广告ID
     * @return 结果
     */
    @Override
    public int deleteIndexAdvertisingById(Long id)
    {
        return indexAdvertisingMapper.deleteIndexAdvertisingById(id);
    }

    @Override
    public int stop(Long id) {
        return indexAdvertisingMapper.stop(id);
    }

    @Override
    public int start(Long id) {
        return indexAdvertisingMapper.start(id);
    }
}
